/*
 * Author  : Pallab
 * Program : D
 *
 * 2011-12-19 14:18:47
 * I have not failed, I have just found 10000 ways that won't work.
 *
 */
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define CI( x ) scanf("%d",&x)
#define CL( x ) scanf("%lld",&x)
#define CD( x ) scanf("%lf",&x )
#define foR(i,st,ed) for(int i = st ; i < ed ; ++i )
#define fo(i,ed) foR( i , 0 , ed )
#define foE(i,st,ed) for(int i = st ; i <= ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )

inline void wait(double seconds) {
    double endtime = clock()+(seconds * CLOCKS_PER_SEC);
    while (clock() < endtime) {
        ;
    }
}
string line;
string result;
int len;
int K;

inline void Read() {
    cin>>line>>K;
    len = LN( line );
}
const int inf = (int)1023456789;
int dp1[502][502];
int dp2[502][502];
int go1(int l, int r) {
    if ( l > r ) {
        return 0;
    }
    if ( dp1[l][r]!=-1 ) {
        return dp1[l][r];
    }
    int best = inf;
    if ( line[l]!=line[r] ) {
        int a = 1+go1( l+1, r-1);
        best = min( best, a );
    }
    if ( line[l]==line[r] ) {
        int a = go1(l+1,r-1);
        best = min( best, a );
    }
    return dp1[l][r]=best;
}
int go2(int indx, int k) {
    if ( indx==len ) {
        return 0;
    }
    if ( dp2[indx][k] !=-1 ) {
        return dp2[indx][k];
    }
    int best = inf;
    if ( k > 0 ) {
        for (int i=indx;i<len;++i) {
            int a = go1(indx,i)+go2(i+1,k-1);
            best = min( best, a );
        }
    }
    return dp2[indx][k]=best;
}
inline void makePalindrome(string &str) {
    int ln = LN(str);
    for (int i=0,j=ln-1; i<=j; ++i,--j ) {
        if ( str[i]!=str[j] ) {
            str[i]=str[j];
        }
    }
    return ;
}
inline void backTrack(int indx, int k,int var) {
    if ( indx==len ) {
        return ;
    }
    if ( k > 0 ) {
        for (int i=indx;i<len;++i) {
            if ( var== go1(indx,i)+go2(i+1,k-1) ) {

                string tmp="";
                for (int j=indx;j<=i;++j) {
                    tmp+=line[j];
                }
                makePalindrome(tmp);
                tmp+='+';
                result+= tmp;
                backTrack(i+1,k-1,var-go1(indx,i));
                break;
            }
        }
    }
    return ;
}
inline void Proc() {
    SET(dp1,-1);
    SET(dp2,-1);
    result="";

    go1( 0, len-1 );
    int var = go2(0,K);
    backTrack(0,K,var);
    if ( result[ LN(result)-1 ]=='+' ) {
        result.erase(LN(result)-1,1);
    }
    cout<<var<<"\n"<<result<<"\n";
}
int main() {
    Read();
    Proc();

    return 0;
}
// kate: indent-mode cstyle; space-indent on; indent-width 0; 
